package com.example.fitnessservice.module.dao.courseMapper;

import com.example.fitnessservice.module.pojo.CourseOrderDetails;
import org.apache.ibatis.annotations.*;

/**
 * @author feng
 * @version 1.0
 * @&#064;description: TODO
 * @&#064;date 2022/11/24 18:14
 */
@Mapper
public interface CourseOrderMapper {
    @Insert("insert into course_order_details (order_time,order_no,order_user_id,order_coach_id,order_course_id,order_status,order_money,order_camp_if)" +
            "values" +
            "(#{orderTime},#{orderNo},#{orderUserId},#{orderCoachId},#{orderCourseId},#{orderStatus},#{orderMoney},#{orderCampIf}) ")
    Integer generateOrder(CourseOrderDetails order);

    @Select("select * from course_order_details where order_user_id=#{userId}")
    CourseOrderDetails findByUserId(Integer userId);

    /*取消课程状态改为6

     */
    @Update("update course_order_details set order_status=6 where order_user_id=#{userId} and order_course_id=#{courseId} and order_camp_if=#{courseCampIf}")
    Integer cancelOrderstatus(@Param("userId") Integer userId, @Param("courseId") Integer courseId, @Param("courseCampIf") Integer courseCampIf);

    @Select("select * from course_order_details where order_user_id=#{userId} and order_course_id=#{courseId} and order_status=2 and order_camp_if=#{courseCampIf}")
    CourseOrderDetails getCourseInfo(@Param("userId") Integer userId, @Param("courseId") Integer courseId, @Param("courseCampIf") Integer courseCampIf);

    @Update("update course_order_details set order_status=#{status} where order_user_id=#{userId} and order_course_id=#{courseId} and order_camp_if=1")
    Integer updataOrderStatus(@Param("courseId") Integer campCourseId, @Param("userId") Integer userId, @Param("status") Integer status);

    @Update("update course_order_details set order_status=4 where order_course_id=#{courseId} and order_camp_if=#{campIf} and order_status=2")
    Integer takeCourse(@Param("courseId") Integer courseId, @Param("campIf") Integer courseCampIf);

    @Update("update course_order_details set order_status=1 where order_course_id=#{courseId} and order_camp_if=#{campIf} and order_status=4")
    Integer finishCourse(@Param("courseId") Integer courseId, @Param("campIf") Integer courseCampIf);
}
